package com.jiaz.controller;

import com.jiaz.service.CategoryService;
import com.jiaz.service.CheckInService;
import com.jiaz.service.PostionService;
import com.jiaz.service.UserService;
import com.jiaz.untils.ResponseBean;
import com.jiaz.vo.QueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author jiajiazi
 * @version 1.0
 * @date 2022/4/24 12:12
 */
@RestController
@Slf4j
@RequestMapping("/data**")
public class UserDataController {

    @Autowired
    private CheckInService checkInService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private PostionService postionService;
    @Autowired
    private UserService userService;

    @RequestMapping("/checkInList")
    public ResponseBean checkinIndex(QueryVo queryVo) {
        if (ObjectUtils.isEmpty(queryVo)) {
            return ResponseBean.error(4008, "参数错误(空值)");
        }
        return checkInService.getCheckInList(queryVo);
    }

    @RequestMapping("/categoryList")
    public ResponseBean categoryIndex(QueryVo queryVo) {
        if (ObjectUtils.isEmpty(queryVo)) {
            return ResponseBean.error(4008, "参数错误(空值)");
        }
        return categoryService.getCatagoryList(queryVo);
    }

    @RequestMapping("/postionList")
    public ResponseBean postionIndex(QueryVo queryVo) {
        if (ObjectUtils.isEmpty(queryVo)) {
            return ResponseBean.error(4008, "参数错误(空值)");
        }
        return postionService.getPostionList(queryVo);
    }


    @RequestMapping("/userList")
    public ResponseBean userIndex(QueryVo queryVo) {
        if (ObjectUtils.isEmpty(queryVo)) {
            return ResponseBean.error(4008, "参数错误(空值)");
        }
        return userService.getUserList(queryVo);
    }
    @RequestMapping("/userFriends")
    public ResponseBean getUserFriends(Integer userId) {
        if (userId == null || userId == 0) {
            return ResponseBean.error(4008, "参数错误(空值或为0)");
        }
        return userService.getUserById(userId);
    }
}
